package com.example.easypan.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.easypan.exception.ServiceException;
import com.example.easypan.pojo.UserInfo;
import com.example.easypan.service.UserInfoService;
import com.example.easypan.mapper.UserInfoMapper;
import org.springframework.stereotype.Service;

/**
* @author 小汤
* @description 针对表【user_info(用户信息)】的数据库操作Service实现
* @createDate 2025-01-30 17:15:40
*/
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
implements UserInfoService{

    @Override
    public UserInfo login(UserInfo user) {
        LambdaQueryWrapper<UserInfo> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(UserInfo::getUserId,user.getUserId());
        UserInfo userdb=getOne(wrapper);

        if(userdb==null)
        {
            throw new ServiceException("用户名不存在");
        }

        if (!user.getPassword().equals(userdb.getPassword())) {
            throw new ServiceException("用户名或密码错误");
        }

        return userdb;
    }
}
